//
//  YYMusicArticleTableViewCell.swift
//  STMusic
//
//  Created by stoneobs on 2017/6/12.
//  Copyright © 2017年 stoneobs. All rights reserved.
//  乐文 cell

import UIKit

class YYMusicArticleTableViewCell: UITableViewCell {

    static var cellHeight:CGFloat = 105;
    
    var indexLable:STLabel?
    
    var titleLable:STLabel?
    
    var scanButton:STButton?
    
    var listenButtton:STButton?
    
    
    var model:YYArticleModel = YYArticleModel(){
    
        didSet{
            
            self.indexLable?.text = model.number;
            
            self.titleLable?.text = model.title;
            
            self.scanButton?.setTitle(model.view_count, for: .normal);
            
            self.listenButtton?.setTitle(model.play_count, for: .normal);
        
        }
    }
    
    
    
    override init(style: UITableViewCellStyle, reuseIdentifier: String?) {
        super.init(style: style, reuseIdentifier: reuseIdentifier);
        self.initSubview();
        self.backgroundColor = UIColor.white.withAlphaComponent(0.7);
    }
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    func initSubview() {
        self.indexLable = STLabel.init(frame: .init(x: 35, y: 0, width: 25, height: 13),
                                       text: "1",
                                       textColor: ThirdTextColor,
                                       font: 13,
                                       isSizetoFit: false,
                                       textAlignment: .left);
        self.indexLable?.centerY = CGFloat(YYMusicArticleTableViewCell.cellHeight/2);
        self.addSubview(self.indexLable!);
        
        self.titleLable = STLabel.init(frame: .init(x: 15 + (self.indexLable?.right)!, y: 25, width: SCREEN_WIDTH - 50 - 20, height: 13),
                                       text: "房东的猫：把美好事物走完",
                                       textColor: FirstTextColor,
                                       font: 15,
                                       isSizetoFit: false,
                                       textAlignment: .left);
        self.addSubview(self.titleLable!);
        
        
        
        self.scanButton = STButton.init(frame: CGRect.init(x: (self.titleLable?.left)!, y: (self.titleLable?.bottom)! + 15, width: 70, height: 14),
                                        title: "123",
                                        titleColor: ThirdTextColor,
                                        titleFont: 13,
                                        cornerRadius: 0,
                                        backgroundColor: .clear,
                                        backgroundImage: nil,
                                        image: UIImage.init(named: "btn_scan"));
        self.scanButton?.contentHorizontalAlignment = .left;
        
        self.scanButton?.titleEdgeInsets = .init(top: 0, left: 5, bottom: 0, right: 0);
        
        self.addSubview(self.scanButton!);
        
        
        self.listenButtton = STButton.init(frame: CGRect.init(x: (self.scanButton?.right)! + 20, y: (self.titleLable?.bottom)! + 15, width: 70, height: 14),
                                        title: "999",
                                        titleColor: ThirdTextColor,
                                        titleFont: 13,
                                        cornerRadius: 0,
                                        backgroundColor: .clear,
                                        backgroundImage: nil,
                                        image: UIImage.init(named: "btn_listen"));
        self.listenButtton?.contentHorizontalAlignment = .left;
        
        self.listenButtton?.titleEdgeInsets = .init(top: 0, left: 5, bottom: 0, right: 0);
        
        self.addSubview(self.listenButtton!);
        
        
        
    }
    override func awakeFromNib() {
        super.awakeFromNib()
        // Initialization code
    }

    override func setSelected(_ selected: Bool, animated: Bool) {
        super.setSelected(selected, animated: animated)

       
    }

}
